package py.edu.ucom.cadira.net.serializables;

import org.jdom.Document;
import org.jdom.Element;

import com.sun.org.apache.bcel.internal.generic.GETSTATIC;

import py.edu.ucom.cadira.net.XMLSerializable;

public class LogoutRequest implements XMLSerializable {
	private String userName;
	
	public LogoutRequest(String userName) {
		this.userName = userName;
	}
	
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Override
	public void fromXML(Document xml) {
		Element root = xml.getRootElement();
		Element logoutNode = root.getChild("logout");
		Element usernameNode = logoutNode.getChild("username");
		setUserName(usernameNode.getValue());

	}

	@Override
	public void toXML(Element root) {
		Element nodeLogout = new Element("logout");
		Element nodeUsername = new Element("username");
		nodeUsername.setText(getUserName());
		nodeLogout.addContent(nodeUsername);
		root.addContent(nodeLogout);

	}

}
